package ahl;

import static org.junit.Assert.assertEquals;
import robocode.control.testing.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * This test will verify whether or not BattleFire always beats SittingDuck.
 * @author Arthur Lee
 */
public class TestBattleFireVsSittingDuck extends RobotTestBed {

  /**
   * Specifies that SittingDuck and BattleFire are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,ahl.BattleFire";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * The actual test, which asserts that BattleFire has won every round against SittingDuck.
   * @param event The completed event.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    //Retrieves the results for both robots.
    BattleResults[] battleResults = event.getIndexedResults();
    //Makes sure that the second index is my robot.
    BattleResults battleFireResults = battleResults[1];
    String robotName = battleFireResults.getTeamLeaderName();
    assertEquals("Check that results[1] is BattleFire", robotName, "ahl.BattleFire*");
    //Checks to make sure that BattleFire has won all ten rounds.
    assertEquals("Check BattleFire winner", battleFireResults.getFirsts(), getNumRounds());
  }
}
